<script type="text/javascript" >
    stPublishToolbox.sortColumn();
    stPublishToolbox.shortAction();
       jQuery(document).ready(function(){
//           jQuery("#helpBtn a[rel^='prettyPhoto']")
           jQuery("#link a[rel^='prettyPhoto']").prettyPhoto({theme:'facebook', keyboard_shortcuts: false});
           
        FB.init({
            appId:'<?php echo $config['facebook_app_id']; ?>', cookie:true,
            status:true, xfbml:true
        });
        <?php if($logoff == 'true'){?>
        <?php echo 'logoff();'; } else {?>
        FB.Event.subscribe('auth.sessionChange', function(response) {
            if (response.session) {
                var access_token = response.session.access_token;
                var session_key = response.session.session_key;
                var uid = response.session.uid;
                stPublishToolbox.loadPage("setting&access_token="+access_token+"&session_key="+session_key+"&uid="+uid+"&login=true", '', '', function(){
                    //window.location = '<?php echo get_bloginfo('url'); ?>/wp-admin/admin.php?page=stPublishToolbox&action=setting';
                });
            }

        });
<?php }?>
    });
    function logoff(){
        FB.getLoginStatus(function(response) {
            if (response.session) {
                FB.logout(function(response) {
                    stPublishToolbox.loadPage("list_wall&login=true", '', '', function(){
                        window.location = '<?php echo get_bloginfo('url'); ?>/wp-admin/admin.php?page=stPublishToolbox&action=setting';
                    });
                });
            } else {
                stPublishToolbox.loadPage("list_wall&login=true", '', '', function(){
                    window.location = '<?php echo get_bloginfo('url'); ?>/wp-admin/admin.php?page=stPublishToolbox&action=setting';
                });
            }
        });


    }
</script>
<div id="fb-root"></div>
<div class="w100p bgl">
    <div class="w100p bgr">
        <div class="inner_container">
            <ul>
           <li>
                    <label><?php _e('Authenticate', $config['plugin_name']); ?>:</label>
            <?php
            $check = 0;
            if ($option['access_token'] != '') {
                $name = json_decode(file_get_contents("https://graph.facebook.com/me?access_token=" . $option['access_token']))->name;
                if ($name != '') {
                    echo 'Status : <font color="green">Authenticated</font>';
                    $check = 1;
                    if ($permission == 1)
                        echo ' - <a href="javascript:void(0);" onclick="stPublishToolbox.loadPage(\'setting&login=true\');" >Logoff</a>';

                }elseif ($permission == 1) {
                    echo "Please authenticate to publish to facebook wall<br />"
                        ."<fb:login-button perms=\"publish_stream,offline_access,manage_pages,publish_checkins\">"
                        ."Authenticate"
                        ."</fb:login-button>";
                }else
                    echo 'Status : <font color="red">Not Connect</font>';

            ?>
            <?php }else { ?>
                               <fb:login-button perms="publish_stream,offline_access,manage_pages,publish_checkins">
                    Authenticate
                </fb:login-button>
            <?php } ?>
           <br clear="both" />
        </li>
        </ul>
            <?php
            if($check != 1){
            ?>
            <style>
            .upcase a {
            display:none;
            }
            </style>
            <?php }?>
            

        </div>
    </div>
</div>